package com.wanho.java157.CustomerManagement.controller;


import com.wanho.java157.CustomerManagement.po.Link;
import com.wanho.java157.CustomerManagement.service.LinkService;
import com.wanho.java157.commons.util.vo.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/link")
public class LinkController {
    @Autowired
    private LinkService linkService;

    @RequestMapping("/list")
    public String list(Model model) {
        model.addAttribute("linkList", linkService.selectAll());
        return "view/customerManage/contacts/index";
    }

    @RequestMapping("/addLink")
    @ResponseBody
    public JSONResult addLink(Link link) {
        // 调用 linkService 新增方法
        System.out.println(link);
        JSONResult jsonResult = new JSONResult();
        jsonResult.setFlag(1);
        jsonResult.setMsg("新增成功");
        return jsonResult;
    }
}
